<?php

namespace app\common\command;

use app\common\service\UserDefinedGet as UserDefinedGetService;
use mes\Mes;
use think\console\Command;
use think\console\Input;
use think\console\input\Option;
use think\console\Output;

/**
 * 自定义导出
 */
class UserDefinedGet extends Command
{

    protected $logName = 'UserDefinedGet';
    protected $mes = '';
    protected $isPrint = 1;    // 是否打印信息到终端
    /**
     * @var \app\common\service\UserDefinedGet
     */
    protected $userDefinedGetService;


    protected function configure()
    {
        $this->setName('UserDefinedGet')
            ->addOption('type', 't', Option::VALUE_OPTIONAL, '分类', '')
            ->setDescription('自定义导出');
        $this->userDefinedGetService = new UserDefinedGetService();
    }

    protected function execute(Input $input, Output $output)
    {
        set_time_limit(0);
        ini_set('memory_limit', '1000M');
        error_reporting(E_ALL & ~E_NOTICE);
        $type = $input->getOption('type');
        switch ($type) {
            default:
//                echo "Done" . PHP_EOL;
                return $this->init();
                break;
        }
    }

    private function init()
    {
        define('FACTORY_IDS', '*');
        $this->userDefinedGetService->head_flag = 0;
        $res = $this->userDefinedGetService->set_excel_data();
        echo "Done,code:{$res['code']} msg:{$res['msg']}" . PHP_EOL;
        return false;
    }
}